//
//  SecondViewController.m
//  Boom
//
//  Created by 云鹏 赵 on 15/3/5.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "SecondViewController.h"
#import "XFDataHandel.h"

@interface SecondViewController ()

@property (nonatomic, assign) BOOL push;

@end

@implementation SecondViewController
- (void)dealloc
{
    [_lable release];
    [_albumArray release];
    [_trackArray release];
    [_searchAlbum release];
    [_searchTrack release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.push = YES;
    
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    // 初始化数组
    self.albumArray = [NSMutableArray array];
    self.trackArray = [NSMutableArray array];
    
    // 本试图控制器用于语音识别搜索 并显示视图
    self.view.backgroundColor = [UIColor colorWithRed:239 / 255.0 green:238 / 255.0 blue:232 / 255.0 alpha:1];
    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
    button1.frame = CGRectMake(162.5, 450, 50, 80);
    button1.backgroundColor = [UIColor clearColor];
    [button1 setImage:[UIImage imageNamed:@"voice_input_speaker@2x.png"] forState:UIControlStateNormal];
    [button1 addTarget:self action:@selector(button1Action:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button1];
    
    UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake(37.5, 100, 300, 30)];
    lable.backgroundColor = [UIColor clearColor];
    lable.font = [UIFont systemFontOfSize:12.0];
    lable.textAlignment = NSTextAlignmentCenter;
    lable.text = @"轻触麦克一下后开始说话";
    lable.textColor = [UIColor colorWithRed:66 / 255.0 green:23 / 255.0 blue:0 alpha:1];
    [self.view addSubview:lable];
    [lable release];
    
    self.lable = [[UILabel alloc] initWithFrame:CGRectMake(37.5, 200, 300, 200)];
    self.lable.textAlignment = NSTextAlignmentCenter;
    self.lable.numberOfLines = 0;
    self.lable.backgroundColor = [UIColor clearColor];
    [self.view addSubview:self.lable];
    [_lable release];

    
}
- (void)button1Action:(UIButton *)button
{
    self.lable.text = nil;
    XFDataHandel *manager = [XFDataHandel shareManager];
    manager.result = [[NSMutableString alloc]init];
    [manager discernBlock:^(NSString *str) {
        self.lable.text = str;
        if (self.push) {
            
            SearhTableViewController *searchTableVC = [[SearhTableViewController alloc] init];
            searchTableVC.str = str;
            [self.navigationController pushViewController:searchTableVC animated:YES];
            [searchTableVC release];
//            [self afnGetData:self.lable.text];
            self.push = NO;
        }
    }];
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.push = YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
